package displayboardinfo.tests;

import java.util.Iterator;

import javax.xml.bind.JAXBException;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class EntitiesTests {
	public static void main(String[] args) throws JAXBException {

		Session session = null;
		try {
//			ListPatientsRes response = new ListPatientsRes();
			
			session = new Configuration().configure().buildSessionFactory()
					.openSession();
//			Transaction transaction = session.beginTransaction();
			String QUERY = "from Patient";
			Query query = session.createQuery(QUERY);
			
			
			
			for (Iterator it = query.iterate(); it.hasNext();) {
				Object item = it.next();
				System.out.println(item);
				
//				Patient pat = (Patient)item;
//				response.addPatient(pat);				
			}
//			
////			JAXBContext context = JAXBContext.newInstance(ListPatientsRes.class);
////			Marshaller m = context.createMarshaller();
////			m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
////			m.marshal(response, System.out);
			
//			Room room = new Room();
//			room.setId(1);
//			
//			RegisteredDisplay display = new RegisteredDisplay();
//			display.setDisplayIp("localhost");
//			display.setDisplayPort(8080);
//			display.setRoom(room);
//			
//			session.save(display);
//			transaction.commit();
		} catch (HibernateException e) {
			e.printStackTrace();
		} finally {
			session.close();
		}
	}
}
